from faker.providers import BaseProvider
import random


# 创建自定义的数据供应商
class CustomProvider(BaseProvider):
    @staticmethod
    def sex():
        # 性别
        sex_list = ['男', '女']
        return random.choice(sex_list)

    @staticmethod
    def advertising_leads():
        # 广告线索
        advertising_leads_list = ['曝光', '点击', '留资']
        return random.choice(advertising_leads_list)

    @staticmethod
    def fans_activity():
        # 粉丝活动 点赞 评论 关注 取关
        fans_activity_list = ['点赞', '评论', '关注', '取关']
        return random.choice(fans_activity_list)

    @staticmethod
    def business_activity():
        # 商业行为 加购 首次购买 复购 退货
        business_activity_list = ['加购', '首次购买', '复购', '退货']
        return random.choice(business_activity_list)

    @staticmethod
    def channel():
        # 渠道值： 微信小程序 微信公众号 企业微信 个人微信   抖音 抖音企业号 短信
        channel_list = ['微信小程序', '微信公众号', '企业微信', '个人微信', '抖音', '抖音企业号', '短信', '微博', '知乎']
        return random.choice(channel_list)

    @staticmethod
    def proxy_terminal():
        # 代理终端类型：  安卓  ios Windows Mac Linux
        proxy_terminal_list = ['Android', 'Ios', 'Windows', 'Mac', 'Linux']
        return random.choice(proxy_terminal_list)

    @staticmethod
    def log_type_list():
        # 日志类型
        log_type_list = ['imp', 'clk', 'nvimp', 'vimp', 'evn']
        return random.choice(log_type_list)

    @staticmethod
    def uuid_type_list():
        # UUid 类型
        uuid_type_list = ['raw_idfa', 'md5_imei', 'device_oaid', 'cookie']
        return random.choice(uuid_type_list)

    @staticmethod
    def os_type_list():
        # 移动端操作系统类型
        os_type_list = ['A', 'i', 'L', 'M', 'S', 'W', 'WP', '']
        return random.choice(os_type_list)

    @staticmethod
    def platform_list():
        # 平台
        platform_list = ['0', '1']
        return random.choice(platform_list)

    @staticmethod
    # # 通过random.randint(a, b)方法得到随机数字
    def generate_random_str(length):
        random_str = ""
        base_str = "ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz0123456789"
        n = len(base_str) - 1
        for i in range(length):
            random_str += base_str[random.randint(0, n)]
        return random_str
